// $Id$
// Licensed under Apache License Version 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0.html
package de.servicezombie.tests;



public abstract class AbstractDataFactory<T> {

	private T bean;
		
	protected AbstractDataFactory() {
		bean = buildDefaultInstance(0);
	}
	
	protected final T getBean() {
		return bean;
	}

	protected abstract T buildDefaultInstance(int index);

	protected String addIndex(String message, int index) {
		return "[" + index + "] " + message;
	}
	
	/**
	 * simply calls getBean()
	 */
	public T build() {		
		return getBean();
	}
	
	public AbstractDataFactory<T> reset(int index) {
		bean = buildDefaultInstance(index);
		return this;
	}	
}
